# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Geoffroy Carrier <geoffroy.carrier@aur.archlinux.org>
# Contributor: Eric Belanger <belanger@astro.umontreal.ca>
# Contributor: aeolist <aeolist@hotmail.com>
# Contributor: Gabriel Rauter <rauter.gabriel@gmail.com>

pkgname=sysprof
pkgver=3.40.1
pkgrel=2
pkgdesc="Kernel based performance profiler"
url="https://wiki.gnome.org/Apps/Sysprof"
license=(GPL)
arch=(x86_64)
depends=(gtk3 polkit libdazzle)
makedepends=(yelp-tools git meson)
groups=(gnome-extra)
_commit=c6840d48d18eaf6b013b550c1551e7954e98d1c8  # tags/3.40.1^0
source=("git+https://gitlab.gnome.org/GNOME/sysprof.git#commit=$_commit")
sha256sums=('SKIP')

_gccver=11
makedepends+=("gcc>=$_gccver" "gcc<$((_gccver + 1))")
conflicts+=("gcc<$_gccver" "gcc>=$((_gccver + 1))")

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^sysprof-//;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  # Ensure static library is non-LTO compatible
  CFLAGS+=" -ffat-lto-objects"

  arch-meson $pkgname build
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  DESTDIR="$pkgdir" meson install -C build
}
